<template>
  <view class="stepper-view">
    <button class="sub-button" type="default" @click.stop="subAction">
      -
    </button>
    <text>{{ count }}</text>
    <button class="add-button" type="default" @click.stop="addAction">
      +
    </button>
  </view>
</template>

<script>
export default {
  props: ["count"],
  emits: ["change"],

  methods: {
    addAction() {
      this.$emit("change", this.count + 1)
    },

    subAction() {
      if (this.count > 0) {
        this.$emit("change", this.count - 1)
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.stepper-view {
  display: flex;
  width: 200rpx;
  height: 60rpx;
  button,
  ::after {
    border: none;
    margin: 0;
    padding: 0;
    width: 60rpx;
    line-height: 60rpx;
  }
  text {
    flex: 1;
    margin: 0 5rpx;
    line-height: 60rpx;
    text-align: center;
    font-size: 26rpx;
    background-color: #f8f8f8;
  }
}
</style>
